<template>
  <div>
    <h1 ref="h1">模板ref使用</h1>
    <el-form ref="form"></el-form>
  </div>
</template>

<script>
import ElForm from '@/views/模板ref使用/son.vue'
import {onMounted, ref} from 'vue'
export default {
  components:{
    ElForm
  },
  setup(){
    const h1 = ref(null)
    const form = ref()
    onMounted(()=> {
      console.log('vue3获取dom对象',h1.value)
      console.log('vue3获取组件实例',form.value)
      form.value.validate()
    })
    return{h1,form}
  },
  mounted(){
    console.log('vue2获取dom对象',this.$refs.h1)
  }
}
</script>

<style>

</style>